package tech.yunland.shop.web;

import com.moyuer.bsf.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tech.yunland.shop.domain.service.SNService;

/**
 * 流水号生成控制器
 * 
 * @author: 袁首京<yuanshoujing@gmail.com>
 * 16/4/28
 */
@RestController
@RequestMapping("/sn")
public class SNController extends BaseController {

    @Autowired
    private SNService snService;

    /**
     * 生成序列号
     *
     * @param key
     * @param organId
     * @return
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String getSn(@RequestParam String key, @RequestParam(required = false) String organId) {
        if (organId == null) {
            organId = primaryOrganId;
        }

        return snService.gen(key, organId);
    }
}
